/*一个用数组实现的队列*/
export default function Queue() {
  this.dataStore = [];//存放队列的数组，初始化为空
  this.enqueue = enqueue;//向队列尾部添加一个元素
  this.dequeue = dequeue;//获取并删除队首的元素
  this.theFirst = theFront;//读取队首的元素
  this.theLast = back;//读取队尾的元素
  this.toStrings = toStrings;//显示队列内的所有元素
  this.isEmpty = empty;//判断队列是否为空
  this.size = size;

  function enqueue(element) {
    this.dataStore.push(element);
  }

  function dequeue() {
    return this.dataStore.shift();
  }

  function theFront() {
    return this.dataStore[0];
  }

  function back() {
    return this.dataStore[this.dataStore.length-1];
  }

  function toStrings() {
    return this.dataStore;
  }

  function empty() {
    return this.dataStore.length === 0;
  }

  function size() {
    return this.dataStore.length;
  }
}
